﻿using System;
using Sinacor.Infra.UI.Common;
using Sinacor.Infra.UI.Security.Services;
using Sinacor.UI.Bovespa.Parametro.Communication.Bovespa.Cliente.Correspondente;

namespace Sinacor.UI.Bovespa.Parametro.Communication
{
    
    public class Correspondente : BaseCommunication
    {
        #region Construtor
        public Correspondente(SessionInformation session)
            : base(session)
        {

        }
        #endregion

        #region Metodos

        //Task : 5435
        //Data :02/03/3009
        //Autor: Andre
        /// <summary>
        /// Retornar a Lista de Correspondente
        /// </summary>
        /// <returns></returns>
        public ModelCollection<Sinacor.UI.Bovespa.Parametro.Model.Correspondente> ConsultarCorrespondentes()
        {
            ICorrespondente servico = null;
            ModelCollection<Sinacor.UI.Bovespa.Parametro.Model.Correspondente> response = null;

            try
            {
                using (ServiceInstance<ICorrespondente> service = new ServiceInstance<ICorrespondente>())
                {
                    servico = service.TryGetInstance(this.Session);
                    response = (new Communication.Translator.DataContractToModel.Correspondente().ToCorrespondente(servico.ConsultarCorrespondentes(new FiltroCorrespondenteRequest())));
                }
            }
            catch (Exception ex)
            {
                base.HandleFault(ex);
            }

            return response;
        }
        #endregion

    } 

}
